<%--
  Created by IntelliJ IDEA.
  User: Admin
  Date: 2016/8/14
  Time: 23:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>addBook</title>
    <style>
        .error{ color: red}
    </style>
</head>
<body>
<c:if test="${!empty requestScope.message}">
    <br>
    <font color="red">${requestScope.message}</font>
    <br><br>
</c:if>
<form method="post" action="/book/save" id="addBookForm">
    作者:<input name="author" placeholder="author" value="${param.author}"><br><br>
    书名:<input name="title" placeholder="title" value="${param.author}"><br><br>
    单价:<input name="price" placeholder="price" value="${param.author}"><br><br>
    出版日期:<input name="publishingDate" placeholder="publishingDate" value="${param.author}"><br><br>
    销量:<input name="salesAmount" placeholder="salesAmount" value="${param.author}"><br><br>
    库存:<input name="storeNumber" placeholder="storeNumber" value="${param.author}"><br><br>
    好评:<input name="remark" placeholder="remark" value="${param.author}"><br><br>
    <button type="submit">保存</button>
    &nbsp;&nbsp;
    <a href="/book/list?pageNo=${bookPage.pageNo}">返回继续购物</a>
</form>
</body>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script >
    $("#addBookForm").validate({
        rules: {
            author:{
                required: true
            },
            title: {
                required: true,
                remote: "/book/checkName"
            },
            price:{
                required: true
            },
            publishingDate: {
              required:true,
                dateISO:true
            }
        }
        ,
        messages: {
            author:{
                required: "author不能为空"
            },
            title: {
                required: "title 不能为空",
                remote: "title已经存在"
            },
            price:{
                required: "price不能为空"
            },
            publishingDate:{
                required:"日期不能为空",
                dateISO:"请填写正确的日期格式:YY-MM-DD"
            }
        }
    });
</script>
</html>
